#include "StdAfx.h"
#include "Circle.h"


CCircle::CCircle(void)
{
}

CCircle::CCircle(CPoint3D pBegin, CPoint3D pEnd)
{
	m_Begin = pBegin;
	m_End = pEnd;
}

CCircle::~CCircle(void)
{
}

void CCircle::Draw()
{
	float dThetaDEG = 360.0/ 100.0;
	float thetaDEG = 0;
	float x, y;

	x = (m_Begin.getX() + m_End.getX())/2;
	y = (m_Begin.getY() + m_End.getY())/2;
	m_pCenter.setCoords(x, y, 0.0f);
	m_w = abs(m_Begin.getX() - m_End.getX())/2;
	m_h = abs(m_Begin.getY() - m_End.getY())/2;
	
	if (selected)
		glColor3fv(blue);
	else 
		glColor3fv(black);
	glPushMatrix();
	glBegin(GL_POLYGON);
		while(thetaDEG < 360.0){
			x = cos(thetaDEG*DEG_2_RAD);
			y = sin(thetaDEG*DEG_2_RAD);
			x = x * m_w + m_pCenter.getX();
			y = y * m_h + m_pCenter.getY();
			glVertex3f(x, y, 0.0f);
			thetaDEG += dThetaDEG;
		}
	glEnd();
	glPopMatrix();
}